import java.util.Arrays;

public class Solution908 {
    public int smallestRangeI(int[] nums, int k) {
        int max= Arrays.stream(nums).max().getAsInt();
        int min= Arrays.stream(nums).min().getAsInt();
        return Math.max(0,max-min-2*k);
    }

    public static void main(String[] args) {
        System.out.println(new Solution908().smallestRangeI(new int[]{0,10},2));
    }
}
